﻿using System;
using System.Collections.Generic;
using SinBiota.Model.Business.PersistenceServices.Interfaces;
using SinBiota.Model.Entities;
using SinBiota.Model.Persistence.Repositories.Interfaces;

namespace SinBiota.Model.Business.PersistenceServices.Implementation
{
    public class MunicipalityPersistenceServices : IMunicipalityPersistenceServices
    {
        private readonly IMunicipalityRepository _municipalityRepository;

        public MunicipalityPersistenceServices(IMunicipalityRepository municipalityRepository)
        {
            _municipalityRepository = municipalityRepository;
        }

        public Municipality FindById(int id)
        {
            return _municipalityRepository.FindById(id);
        }

        public Municipality FindByName(string name)
        {
            return _municipalityRepository.FindByName(name);
        }


        public IList<Municipality> FindAll()
        {
            return _municipalityRepository.FindAll();
        }

        public void Delete(Municipality municipality)
        {
            _municipalityRepository.Delete(municipality);
        }

        public void DeleteById(int id)
        {
            Delete(FindById(id));
        }
        public void Save(Municipality municipality)
        {
            _municipalityRepository.Save(municipality);
        }

        public void Update(Municipality municipality)
        {
            _municipalityRepository.Update(municipality);
        }

        public IList<Municipality> FindByState(State state)
        {
            return _municipalityRepository.FindByState(state);
        }

        public IList<Municipality> FindByNameLike(string name, State? state)
        {
            return _municipalityRepository.FindByNameLike(name, state);
        }
    }
}